//
//  BookView.m
//  cifNews_iphone
//
//  Created by  on 12-6-8.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "BookView.h"

@implementation BookView
@synthesize img,titleLab,periodLab;

-(void)dealloc{
    [titleLab release];
    [periodLab release];
    [img release];
    [super dealloc];
}

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor=[UIColor clearColor];
        img=[[UIImageView alloc] initWithFrame:CGRectMake(15, 15, 110, 145)];
        img.image=[UIImage imageNamed:@"smallloading.png"];
        [self addSubview:img];
        
        UIImageView* labelImg=[[UIImageView alloc] initWithFrame:CGRectMake(10, 120, 127, 45)];
        labelImg.image=[UIImage imageNamed:@"redlabel.png"];
        labelImg.userInteractionEnabled=YES;
        [self addSubview:labelImg];
        [labelImg release];        
        titleLab=[[UILabel alloc] initWithFrame:CGRectMake(5, 8, 75, 20)];
        titleLab.text=@"期刊名字";
        titleLab.textAlignment=UITextAlignmentRight;
        titleLab.textColor=[UIColor whiteColor];
        titleLab.backgroundColor=[UIColor clearColor];
        titleLab.font=[UIFont boldSystemFontOfSize:14];
        
        periodLab=[[UILabel alloc] initWithFrame:CGRectMake(5, 28, 75, 15)];
        periodLab.font=[UIFont systemFontOfSize:12];
        periodLab.textColor=[UIColor whiteColor];
        periodLab.backgroundColor=[UIColor clearColor];
        periodLab.textAlignment=UITextAlignmentRight;
        periodLab.text=@"出版日期";
        [labelImg addSubview:titleLab];
        [labelImg addSubview:periodLab];
        
        UIButton* but=[UIButton buttonWithType:UIButtonTypeCustom];
        but.frame=CGRectMake(83, 12, 40, 30);
        but.titleLabel.font=[UIFont systemFontOfSize:12];
        [but addTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];
        [but setTitle:@"下载" forState:UIControlStateNormal];
        [but setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [but setTitleColor:[UIColor darkGrayColor] forState:UIControlStateSelected];
        [but setTitleColor:[UIColor redColor] forState:UIControlStateReserved];
        [labelImg addSubview:but];
    }
    return self;
}

- (void)btnClicked:(UIButton*)sender{
    if(sender.selected){
//        已经下载完成
    }else {
//        送去下载
        [sender setTitle:@"下载中" forState:UIControlStateNormal];
    }
    sender.selected=YES;

}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
